package arabicScrabble;

import java.awt.GridLayout;
import java.awt.Image;
import java.util.LinkedList;

import javax.swing.JPanel;

public class Bag extends JPanel {

	/**
	 *
	 */
	private static final long serialVersionUID = 6241362865099569762L;
	private LinkedList<Letter> letter = new LinkedList<Letter>();

	public void removeLetter(Letter x) {
		super.remove(x);
		letter.remove(x);

	}

	public Letter removeLetter(int x) {
		super.remove(letter.get(x));
		return letter.remove(x);

	}

	public LinkedList<Letter> getLetters() {
		return letter;
	}

	public Letter getLetter(int x) {
		return letter.get(x);
	}

	public void addLetter(Letter x) {

		super.add(x);
		letter.add(x);

	}


	Bag(boolean arabic) {
		this.setLayout(new GridLayout(15, 15));
		if (arabic) {

			//Letter myLet = new Letter('ا', 1, "Letter Valuse/Alif.png");
			//myLet.setSize(5, 5);

		for (int ا = 0; ا < 8; ا++)
				     addLetter(new Letter('ا', 1, "Letter Valuse/Alif.png"));

				  for (int ب = 9; ب < 11; ب++)
				     addLetter(new Letter('ب', 2, "Letter Valuse/Ba2.png"));

				  for (int ت = 11; ت < 13; ت++)
				     addLetter(new Letter('ت', 2, "Letter Valuse/Ta2.png"));

				  for (int ث = 13; ث < 17; ث++)
				     addLetter(new Letter('ث', 2, "Letter Valuse/Tha2.png"));

				  for (int ج = 17; ج < 29; ج++)
				     addLetter(new Letter('ج', 1, "Letter Valuse/Jem.png"));

				  for (int ح = 29; ح < 31; ح++)
				     addLetter(new Letter('ح', 1, "Letter Valuse/7a2.png"));

				  for (int خ = 31; خ < 34; خ++)
				     addLetter(new Letter('خ', 1, "Letter Valuse/Kha2.png"));

				  for (int د = 34; د < 36; د++)
				     addLetter(new Letter('د', 2, "Letter Valuse/Dal.png"));

				  for (int ذ = 36; ذ < 45; ذ++)
				     addLetter(new Letter('ذ', 3, "Letter Valuse/Thal.png"));

				  for (int ر = 45; ر < 46; ر++)
				     addLetter(new Letter('ر', 2, "Letter Valuse/Ra2.png"));

				  for (int ز = 46; ز < 47; ز++)
				     addLetter(new Letter('ز', 3, "Letter Valuse/Zai.png"));

				  for (int س = 47; س < 51; س++)
				     addLetter(new Letter('س', 2, "Letter Valuse/Sen.png"));

				  for (int ش = 51; ش < 53; ش++)
				     addLetter(new Letter('ش', 3, "Letter Valuse/Shen.png"));

				  for (int ص = 53; ص < 59; ص++)
				     addLetter(new Letter('ص', 4, "Letter Valuse/9ad.png"));

				  for (int ض = 59; ض < 67; ض++)
				     addLetter(new Letter('ض', 4, "Letter Valuse/Thad.png"));

				  for (int ط = 67; ط < 69; ط++)
				     addLetter(new Letter('ط', 4, "Letter Valuse/6a2.png"));

				  for (int ظ = 69; ظ < 70; ظ++)
				     addLetter(new Letter('ظ', 5, "Letter Valuse/Tha.png"));

				  for (int ع = 70; ع < 76; ع++)
				     addLetter(new Letter('ع', 4, "Letter Valuse/3ain.png"));

				  for (int غ = 76; غ < 80; غ++)
				     addLetter(new Letter('غ', 8, "Letter Valuse/Ghain.png"));

				  for (int ف = 80; ف < 86; ف++)
				     addLetter(new Letter('ف', 3, "Letter Valuse/Fa2.png"));

				  for (int ق = 86; ق < 90; ق++)
				     addLetter(new Letter('ق', 3, "Letter Valuse/8af.png"));

				  for (int ك = 90; ك < 94; ك++)
				     addLetter(new Letter('ك', 4, "Letter Valuse/Kaf.png"));

				  for (int ل = 94; ل < 95; ل++)
				     addLetter(new Letter('ل', 1, "Letter Valuse/Lam.png"));

				  for (int م = 95; م < 96; م++)
				     addLetter(new Letter('م', 1, "Letter Valuse/Mem.png"));

				  for (int ن = 96; ن < 98; ن++)
				     addLetter(new Letter('ن', 1, "Letter Valuse/Non.png"));

				  for (int ه = 98; ه < 99; ه++)
				     addLetter(new Letter('ه', 1, "Letter Valuse/Ha2.png"));

				  for (int و = 98; و < 99; و++)
				     addLetter(new Letter('و', 1, "Letter Valuse/Waw.png"));
				  for (int ي = 98; ي < 99; ي++)
				     addLetter(new Letter('ي', 1, "Letter Valuse/Ya2.png"));

				  for (int bt = 99; bt < 100; bt++)
				     // missing one blank tile!
				     addLetter(new Letter('.', 0, "Letter Valuse/BlankTile.png"));

			   for (int bt = 99; bt < 100; bt++)
			    // missing one blank tile!
			    addLetter(new Letter(' ', 0, "Letter Valuse/BlankTile.png"));
		} else {

			for (int a = 0; a < 9; a++)
				addLetter(new Letter('a', 1, "Eng Scrabble Tiles/A.png"));

			for (int b = 9; b < 11; b++)
				addLetter(new Letter('b', 3, "Eng Scrabble Tiles/B.png"));

			for (int c = 11; c < 13; c++)
				addLetter(new Letter('c', 3, "Eng Scrabble Tiles/C.png"));

			for (int d = 13; d < 17; d++)
				addLetter(new Letter('d', 2, "Eng Scrabble Tiles/D.png"));

			for (int e = 17; e < 29; e++)
				addLetter(new Letter('e', 1, "Eng Scrabble Tiles/E.png"));

			for (int f = 29; f < 31; f++)
				addLetter(new Letter('f', 4, "Eng Scrabble Tiles/F.png"));

			for (int g = 31; g < 34; g++)
				addLetter(new Letter('g', 2, "Eng Scrabble Tiles/G.png"));

			for (int h = 34; h < 36; h++)
				addLetter(new Letter('h', 4, "Eng Scrabble Tiles/H.png"));

			for (int i = 36; i < 45; i++)
				addLetter(new Letter('i', 1, "Eng Scrabble Tiles/I.png"));

			for (int j = 45; j < 46; j++)
				addLetter(new Letter('j', 8, "Eng Scrabble Tiles/J.png"));

			for (int k = 46; k < 47; k++)
				addLetter(new Letter('k', 5, "Eng Scrabble Tiles/K.png"));

			for (int l = 47; l < 51; l++)
				addLetter(new Letter('l', 1, "Eng Scrabble Tiles/L.png"));

			for (int m = 51; m < 53; m++)
				addLetter(new Letter('m', 3, "Eng Scrabble Tiles/M.png"));

			for (int n = 53; n < 59; n++)
				addLetter(new Letter('n', 1, "Eng Scrabble Tiles/N.png"));

			for (int o = 59; o < 67; o++)
				addLetter(new Letter('o', 1, "Eng Scrabble Tiles/O.png"));

			for (int p = 67; p < 69; p++)
				addLetter(new Letter('p', 3, "Eng Scrabble Tiles/P.png"));

			for (int q = 69; q < 70; q++)
				addLetter(new Letter('q', 10, "Eng Scrabble Tiles/Q.png"));

			for (int r = 70; r < 76; r++)
				addLetter(new Letter('r', 1, "Eng Scrabble Tiles/R.png"));

			for (int s = 76; s < 80; s++)
				addLetter(new Letter('s', 1, "Eng Scrabble Tiles/S.png"));

			for (int t = 80; t < 86; t++)
				addLetter(new Letter('t', 1, "Eng Scrabble Tiles/T.png"));

			for (int u = 86; u < 90; u++)
				addLetter(new Letter('u', 1, "Eng Scrabble Tiles/U.png"));

			for (int v = 90; v < 94; v++)
				addLetter(new Letter('v', 4, "Eng Scrabble Tiles/V.png"));

			for (int w = 94; w < 95; w++)
				addLetter(new Letter('w', 4, "Eng Scrabble Tiles/W.png"));

			for (int x = 95; x < 96; x++)
				addLetter(new Letter('x', 8, "Eng Scrabble Tiles/X.png"));

			for (int y = 96; y < 98; y++)
				addLetter(new Letter('y', 4, "Eng Scrabble Tiles/Y.png"));

			for (int z = 98; z < 99; z++)
				addLetter(new Letter('z', 10, "Eng Scrabble Tiles/Z.png"));

			for (int bt = 99; bt < 100; bt++)
				// missing one blank tile!
				addLetter(new Letter('.', 0, "Eng Scrabble Tiles/blankTile.png"));
		}

	}
}
